package com.csdn.ingo.dao.ctrip.search.dictionary.productscore;

/**
 * @Author: ycy
 * @CreateDate: 2019/7/19 11:05
 */
public class LevelScore {

  public static final String SCOREDESC_DISTANCESCORE = "%s=(%s)(distanceScore)";

  public static void main(String[] args) {
    int distance = 1198 ; // 50
    get(distance);
    int distance2 = 1221; // 40
   get(distance2);
  }

  public static void get(int distance){
    int maxDistance  = 2000;
    int level = 10;
    int maxScore = 100;
    int distanceLevel = maxDistance / level;
    int scoreLevel = maxScore / level;
    for (int i = 0; i < level; i++) {
      if (distance <= distanceLevel * (i + 1)) {
        int distanceScore = maxScore - (i * scoreLevel);
        System.out.println(String.format(SCOREDESC_DISTANCESCORE, distanceScore, distance));
        return;
      }
    }
  }

}
